unit F_runstat;

interface

uses
  Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
  StdCtrls, ExtCtrls, Buttons;

type
  TFrun = class(TForm)
    labstat: TLabel;
    Timer1: TTimer;
    Label1: TLabel;
    sbclose: TSpeedButton;
    Panel1: TPanel;
    Label2: TLabel;
    Label3: TLabel;
    Label4: TLabel;
    lnew: TLabel;
    ldest: TLabel;
    lmes: TLabel;
    Label5: TLabel;
    lbat: TLabel;
    Label6: TLabel;
    luncol: TLabel;
    Timer2: TTimer;
    procedure FormActivate(Sender: TObject);
    procedure Timer1Timer(Sender: TObject);
    procedure sbcloseClick(Sender: TObject);
    procedure FormCloseQuery(Sender: TObject; var CanClose: Boolean);
    procedure FormKeyDown(Sender: TObject; var Key: Word;
      Shift: TShiftState);
    procedure Timer2Timer(Sender: TObject);
  private
    { Private declarations }
  public
    { Public declarations }
  end;

var
  Frun: TFrun;
  hruning:boolean;

implementation

uses hstruct;

{$R *.DFM}

procedure TFrun.FormActivate(Sender: TObject);
begin
 caption:=run_gamename;
 lbat.caption:='0';
 lmes.caption:='0';
 lnew.caption:='0';
 ldest.caption:='0';
 sbclose.enabled:=false;
 labstat.font.Color:=clpurple;
 hruning:=true;
 timer1.enabled:=true;
 hht.NormalHost(basedir,application);
 labstat.font.Color:=clgreen;
 sbclose.enabled:=true;
 if packet_run then timer2.enabled:=true;
end;

procedure TFrun.Timer1Timer(Sender: TObject);
begin
 try
 if labstat.caption<>hoststat then labstat.caption:=hoststat;
 if strtoint(lmes.caption)<>hrunmes then lmes.caption:=inttostr(hrunmes);
 if strtoint(ldest.caption)<>hrundes then ldest.caption:=inttostr(hrundes);
 if strtoint(lnew.caption)<>hrunnew then lnew.caption:=inttostr(hrunnew);
 if strtoint(lbat.caption)<>hrunbat then lbat.caption:=inttostr(hrunbat);
 if strtoint(luncol.caption)<>hrununitkol then luncol.caption:=inttostr(hrununitkol);
 except
 end;
end;

procedure TFrun.sbcloseClick(Sender: TObject);
begin
 hruning:=false;
 timer1.enabled:=false;
 close;
end;

procedure TFrun.FormCloseQuery(Sender: TObject; var CanClose: Boolean);
begin
  //if not hruning then begin timer1.enabled:=false;canclose:=true;end else canclose:=false;
  canclose := true;
end;

procedure TFrun.FormKeyDown(Sender: TObject; var Key: Word;
  Shift: TShiftState);
begin
   if sbclose.Enabled=true then 
   if (key=13) or (key=27) then sbcloseclick(sender)
end;

procedure TFrun.Timer2Timer(Sender: TObject);
begin
 timer2.enabled:=false;
 sbcloseclick(sender);
end;

end.
